<%--
功能: 显示货品价格
--%>
<%@ tag body-content="empty" pageEncoding="UTF-8"%>
<%@ taglib tagdir="/WEB-INF/tags/common"  prefix="common"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ tag import="org.springframework.context.ApplicationContext" %>
<%@ tag import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ tag import="com.probiz.estore.common.service.PromoService" %>
<%@	tag import="com.probiz.estore.common.model.product.ProductSku"%>
<%@ tag import="java.math.BigDecimal" %>
<%@	tag import="java.util.List"%>

<%@ attribute name="productSku" required="true" rtexprvalue="true" type="com.probiz.estore.common.model.product.ProductSku"%>
<%@ attribute name="multiple" required="false" rtexprvalue="true"  type="java.lang.Boolean" description="是否显示两个价格，是则显示两个价格，否则显示一个价格,默认是false"%>
<%@ attribute name="hasPriceName" required="false" rtexprvalue="true"  type="java.lang.Boolean" description="是否有价格文字说明，默认是false"%>
<%@ attribute name="hasSave" required="false" rtexprvalue="true"  type="java.lang.Boolean" description="是否有节省，默认是false"%>
<%
	if(multiple==null)multiple=false;
	if(hasPriceName==null)hasPriceName=false;
	ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(session.getServletContext());
	PromoService promoService = (PromoService) ctx.getBean("promoService");
	promoService.appendPromoInfo(productSku);
	BigDecimal[] viewPrices = productSku.getViewPrices();
	request.setAttribute("viewType",productSku.getPriceViewType());
	request.setAttribute("viewPrices",viewPrices);
	 
%>
<div class="price">
	<c:choose>
		<c:when test="${!multiple}">
			<%--一个价--%>
			<p><ins><common:currencyFormat value="${viewPrices[1]}" /></ins></p>
		</c:when>
		
		<c:otherwise>
			<%--两个价--%>
			<c:choose>
				<c:when test="${viewType==1}">
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.listPrice" />:</span>
						</c:if>
						<del><common:currencyFormat value="${viewPrices[0]}" /></del>
					</p>
					<p>	
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.ourPrice" />: </span>
						</c:if>
						<ins><common:currencyFormat value="${viewPrices[1]}" /></ins>
						<c:if test="${hasSave and ((viewPrices[0]-viewPrices[1])> 0.00)}"><span class="save"><span class="caption"><fmt:message key="productDetail.save" /></span><common:currencyFormat value="${viewPrices[0]-viewPrices[1]}" /></span></c:if>
					</p>
				</c:when>
				<c:when test="${viewType==2}">
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.ourPrice" />: </span>
						</c:if>
						<del><common:currencyFormat value="${viewPrices[0]}" /></del>
					</p>
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.salePrice" />:</span>
						</c:if>
						<ins><common:currencyFormat value="${viewPrices[1]}" /></ins>
						<c:if test="${hasSave and ((viewPrices[0]-viewPrices[1])> 0.00)}"><span class="save"><span class="caption"><fmt:message key="productDetail.save" /></span><common:currencyFormat value="${viewPrices[0]-viewPrices[1]}" /></span></c:if>
					</p>
				</c:when>
				<c:when test="${viewType==3}">
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.ourPrice" />:</span> 
						</c:if>
						<del><common:currencyFormat value="${viewPrices[0]}" /></del>
					</p>
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.discountPrice" />:</span>
						</c:if>
						<ins><common:currencyFormat value="${viewPrices[1]}" /></ins>
						<c:if test="${hasSave and ((viewPrices[0]-viewPrices[1])> 0.00)}"><span class="save"><span class="caption"><fmt:message key="productDetail.save" /></span><common:currencyFormat value="${viewPrices[0]-viewPrices[1]}" /></span></c:if>
					</p>
				</c:when>
				<c:when test="${viewType==4}">
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.ourPrice" />: </span>
						</c:if>
						<ins><common:currencyFormat value="${viewPrices[1]}" /></ins>
						<c:if test="${hasSave and ((viewPrices[0]-viewPrices[1])> 0.00)}"><span class="save"><span class="caption"><fmt:message key="productDetail.save" /></span><common:currencyFormat value="${viewPrices[0]-viewPrices[1]}" /></span></c:if>
					</p>
				</c:when>
				<c:when test="${viewType==5}">
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.formerPrice" />: </span>
						</c:if>
						<del><common:currencyFormat value="${viewPrices[0]}" /></del>
					</p>
					<p>
						<c:if test="${hasPriceName}"><span class="caption"><fmt:message key="productDetail.packagePrice" />:</span>
						</c:if>
						<ins><common:currencyFormat value="${viewPrices[1]}" /></ins>
						<c:if test="${hasSave and ((viewPrices[0]-viewPrices[1])> 0.00)}"><span class="save"><span class="caption"><fmt:message key="productDetail.save" />:</span><common:currencyFormat value="${viewPrices[0]-viewPrices[1]}" /></span></c:if>
					</p>
				</c:when>
				<c:otherwise>
				</c:otherwise>
			</c:choose>
		</c:otherwise>
			
	</c:choose>
</div>	
